<?php
global $wp_query;
$image_width = get_option('product_image_width');
$image_height = get_option('product_image_height');
?>
<?php if(wpsc_product_count() >= 1):?>
<div class="breadcrumbs"><?php wpsc_output_breadcrumbs(array('show_home_page'=>false,'show_products_page'=>false)); ?></div>
<?php else: ?>
<?php cc_display_breadcrumb_cat(); ?>
<?php endif ; ?>
<div>
	<?php do_action('wpsc_top_of_products_page'); // Plugin hook for adding things to the top of the products page, like the live search ?>
	<?php if(wpsc_display_products()): ?>
	<?php if(wpsc_is_in_category()) : ?>
		<div class="wpsc_category_details">
			<?php if(get_option('show_category_thumbnails') && wpsc_category_image()) : ?>
				<img src="<?php echo wpsc_category_image(); ?>" alt="<?php echo wpsc_category_name(); ?>" title="<?php echo wpsc_category_name(); ?>" />
			<?php endif; ?>
			
			<?php if(get_option('wpsc_category_description') &&  wpsc_category_description()) : ?>
				<?php echo wpsc_category_description(); ?>
			<?php endif; ?>
		</div><!--close wpsc_category_details-->
	<?php endif; ?>
	
	
	<?php if(wpsc_has_pages_top()) : ?>
			<div class="wpsc_page_numbers_top group">
				<?php wpsc_pagination(); ?>
			</div><!--close wpsc_page_numbers_top-->
	<?php endif; ?>		
		

	<div class="product_grid_display group">
		<?php if(wpsc_product_count() >= 1):?>
		<div class="product_list_holder clear">
			<?php while (wpsc_have_products()) :  wpsc_the_product(); ?>
						<div class="product_list_box left product_view_<?php echo wpsc_the_product_id(); ?>">
							<form class="product_form"  enctype="multipart/form-data" action="<?php echo wpsc_this_page_url(); ?>" method="post" name="product_<?php echo wpsc_the_product_id(); ?>" id="product_<?php echo wpsc_the_product_id(); ?>" >
								<?php do_action ( 'wpsc_product_form_fields_begin' ); ?>
								<input type="hidden" value="add_to_cart" name="wpsc_ajax_action"/>
								<input type="hidden" value="<?php echo wpsc_the_product_id(); ?>" name="product_id"/>
								<?php if(get_option('display_variations') == 1) : ?>
									<?php /** the variation group HTML and loop */ ?>
									<?php if (wpsc_have_variation_groups()) : ?>
												<fieldset><legend><?php _e('Product Options', 'wpsc'); ?></legend>       
													<div class="wpsc_variation_forms">
														<table>
														<?php while (wpsc_have_variation_groups()) : wpsc_the_variation_group(); ?>
															<tr><td class="col1"><label for="<?php echo wpsc_vargrp_form_id(); ?>"><?php echo wpsc_the_vargrp_name(); ?>:</label></td>
															<?php /** the variation HTML and loop */?>
															<td class="col2"><select class="wpsc_select_variation" name="variation[<?php echo wpsc_vargrp_id(); ?>]" id="<?php echo wpsc_vargrp_form_id(); ?>">
															<?php while (wpsc_have_variations()) : wpsc_the_variation(); ?>
																<option value="<?php echo wpsc_the_variation_id(); ?>" <?php echo wpsc_the_variation_out_of_stock(); ?>><?php echo wpsc_the_variation_name(); ?></option>
															<?php endwhile; ?>
															</select></td></tr> 
														<?php endwhile; ?>
														</table>
													</div><!--close wpsc_variation_forms-->
												</fieldset>
										<?php /** the variation group HTML and loop ends here */?>
										<?php endif; ?>
								<?php endif ?>
								<div class="product_list_image">
									<?php if(wpsc_the_product_thumbnail()) :?> 	
										<div class="item_image">
											<a href="<?php echo wpsc_the_product_permalink(); ?>">
											<img style="height:<?php echo get_option('product_image_height'); ?>px" class="product_image" id="product_image_<?php echo wpsc_the_product_id(); ?>" alt="<?php echo wpsc_the_product_title(); ?>" src="<?php echo wpsc_the_product_thumbnail(); ?>" />
											</a>
										</div><!--close imte_image-->
									<?php else: ?> 
										<div class="item_no_image">
											<a href="<?php echo wpsc_the_product_permalink(); ?>">
												<img class="no-image" id="product_image_<?php echo wpsc_the_product_id(); ?>" alt="No Image" title="<?php echo wpsc_the_product_title(); ?>" src="<?php echo WPSC_CORE_THEME_URL; ?>wpsc-images/noimage.png" width="<?php echo get_option('product_image_width'); ?>" height="<?php echo get_option('product_image_height'); ?>" />
											</a>
										</div><!--close item_no_image-->
									<?php endif; ?> 
								</div>
								<div class="product_list_title"><a href="<?php echo wpsc_the_product_permalink(); ?>" title="<?php echo wpsc_the_product_title(); ?>"><?php echo wpsc_the_product_title(); ?></a></div>
								<div class="product_list_price clear">
									<div class="price left"><?php echo wpsc_product_normal_price(); ?></div>
									<div class="qty left">
										<?php
										/**
										 * Quantity options - MUST be enabled in Admin Settings
										 */
										?>
										<?php if(wpsc_has_multi_adding()): ?>
											<div class="wpsc_quantity_update">
												<input type="text" id="wpsc_quantity_update_<?php echo wpsc_the_product_id(); ?>" name="wpsc_quantity_update" size="2" value="1" class="input_qty"/>
												<input type="hidden" name="key" value="<?php echo wpsc_the_cart_item_key(); ?>"/>
												<input type="hidden" name="wpsc_update_quantity" value="true" />
											</div><!--close wpsc_quantity_update-->
										<?php endif ;?>
									</div>
									<div class="add_cart left">
										<?php if((get_option('display_addtocart') == 1) && (get_option('addtocart_or_buynow') !='1')) :?> 	   
											<?php if(wpsc_product_has_stock()) : ?>
												<input type="submit" value="<?php _e('Add To Cart', 'wpsc'); ?>" name="Buy" class="wpsc_buy_button" id="product_<?php echo wpsc_the_product_id(); ?>_submit_button"/>
											<?php else : ?>
												<p class="soldout"><?php _e('Sorry, sold out!', 'wpsc'); ?></p>
											<?php endif ; ?>
										<?php endif; ?>
									</div>
								</div>
								<div class="wpsc_loading_animation">
									<img title="Loading" alt="Loading" src="<?php echo wpsc_loading_animation_url(); ?>" />
									<?php _e('Updating cart...', 'wpsc'); ?>
								</div><!--close wpsc_loading_animation-->
								<?php do_action ( 'wpsc_product_form_fields_end' ); ?>
							</form>
						</div><!-- product_list_box close -->
				<?php if((get_option('grid_number_per_row') > 0) && ((($wp_query->current_post +1) % get_option('grid_number_per_row')) == 0)) :?>
				  <div class="grid_view_clearboth"></div>
				<?php endif ; ?>
			<?php endwhile; ?>
		</div>
		<?php endif ; ?>
		<?php if(wpsc_product_count() == 0):?>
			
			<div style="font-size:24px; text-align:center; margin-top:100px;"><?php  _e('There are no products in this category.', 'wpsc'); ?></div>
			<div style="text-align:center;">Please contact us or do a search for the product that you like.</div>
			
			<div class="featured_products" style="margin-top:150px">
				<div class="featured_products_title">Other products you might also be interested in</div>
				<div class="featured_products_content">
					<?php require('wpsc-random_product.php');?>
				</div><!-- end featured banner -->
				
			</div>
		<?php endif ; ?>
		
		
	</div><!--close product_grid_display-->
	<?php if(wpsc_product_count() >= 1):?>
			<?php if(wpsc_has_pages_bottom()) : ?>
					<div class="wpsc_page_numbers_bottom">
						<?php wpsc_pagination(); ?>
					</div><!--close wpsc_page_numbers_bottom-->
			<?php endif; ?>
		<?php endif; ?>
	<?php endif ; ?>
    <?php do_action( 'wpsc_theme_footer' ); ?> 	

</div><!--close grid_view_products_page_container-->
